# 保存汉王的json数据
import json
import os
from tqdm import tqdm
from common.get_hw_pre import getresult

dir = "E:/internship/dataset_test/format_new/9.1"
fw = open(os.path.join(dir, "hw_bo_result.txt"), "w", encoding="utf-8")
fr = open(os.path.join(dir, "Label.txt"), "r", encoding='utf-8')
lines = fr.readlines()
for line in tqdm(lines):
    strs = line.split("\t")
    filename = strs[0]
    # filename = filename.split(".")[0] + ".jpg"
    # path = os.path.join(dir, filename)
    path = os.path.join(dir, "../" + filename)
    pre = getresult(path)
    fw.write(filename + "\t" + json.dumps(pre, ensure_ascii=False) + "\n")
fw.close()
fr.close()